package com.Practice;

public class SingTon {
    private SingTon(){
        System.out.println("init");
    }
    private static SingTon instance;
    public static SingTon getInstance(){
        synchronized (SingTon.class){
            if (instance == null){
                instance = new SingTon();
            }
        }
        return instance;
    }
}

class Test{
    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                SingTon.getInstance();
            }).start();
        }
    }
}
